<template>
  <div v-show="props.compType === 'link'">
    <el-form-item label="ID">
      <el-tooltip
          class="item"
          effect="dark"
          content="请注意,ID的修改可能会导致该组件相关事件失效！"
          placement="left"
      >
        <el-input class="input" v-model="props.id" @change="handlerChangeGetId"></el-input>
      </el-tooltip>
    </el-form-item>
    <el-form-item label="链接文字">
      <el-input class="input" v-model="props.text"></el-input>
    </el-form-item>
    <el-form-item label="类型">
      <el-select v-model="props.type" placeholder="请选择">
        <el-option label="primary" value="primary"/>
        <el-option label="success" value="success"/>
        <el-option label="warning" value="warning"/>
        <el-option label="danger" value="danger"/>
        <el-option label="info" value="info"/>
      </el-select>
    </el-form-item>
    <el-form-item label="url">
      <el-input class="input" v-model="props.href"></el-input>
    </el-form-item>
    <el-form-item label="禁用">
      <el-switch v-model="props.disabled"></el-switch>
    </el-form-item>
    <!-- <el-form-item label="新窗口">
      <el-switch v-model="props.isNewWindow" @change="handlerChangeTargetValue"></el-switch>
    </el-form-item> -->
  </div>
</template>
<script lang="ts">
import {changeId, type FormDesignerMixin} from '../mixin/FormDesignerMixin';
import {Component, Prop} from 'web-decorator-vue';

@Component({
  name: 'fd-link',
  mixins: [changeId],
})
export default class FDLink implements FormDesignerMixin {
  // TODO 补齐作用
  @Prop() props: any;

  // TODO 补齐作用
  handlerShowLabel(val: any) {
    if (val) {
      this.props.labelWidth = 80;
    } else {
      this.props.labelWidth = 0;
    }
  }

  // TODO 补齐作用
  handlerChangeTargetValue(val: any) {
    if (val) {
      this.props.target = '_blank';
    } else {
      this.props.target = '_self';
    }
  }
  // TODO 补齐注释
  // 数据属性
  handlerChangeIdCallback?: Function;
  
  // 方法
  handlerChangeGetId(val: any) {
    if (this.handlerChangeIdCallback) {
      this.handlerChangeIdCallback(val);
    }
  }
}
</script>
